import Vue from 'vue';

import Cookies from 'js-cookie';
import GlobalError from './utils/error';

import 'normalize.css/normalize.css'; // a modern alternative to CSS resets

import Element from 'element-ui';
import './styles/element-variables.scss';

import '@/styles/index.scss'; // global css

import App from './App';
import store from './store';
import router from './router';

import './icons'; // icon
import './permission'; // permission control
import Null from '@/directive/null/index';

import * as filters from './filters'; // global filters

Vue.use(Null);
Vue.use(GlobalError);
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
});

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

// Vue.prototype.$http = http
Vue.config.productionTip = false;
// Event Bus
Vue.prototype.$Bus = new Vue();
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
});
